From 1afb532646f898fb3f510a4b3001e9a01c1dbdd9 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Thu, 11 Mar 2004 08:29:36 +0000 Subject: [PATCH] bitkeeper revision 1.778.1.1 (40502370V4WBJ27H6luInkhjjlnUBA) traps.c, pdb-stub.c: Enable interrupts in exception handlers. --- xen/arch/i386/pdb-stub.c | 2 +- xen/arch/i386/traps.c | 68 +++++++++++++++++++++++++--------------- 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/xen/arch/i386/pdb-stub.c b/xen/arch/i386/pdb-stub.c index e92e5cf30a..3f905b3f05 100644 --- a/xen/arch/i386/pdb-stub.c +++ b/xen/arch/i386/pdb-stub.c @@ -29,7 +29,7 @@ static int pdb_stepping = 0; void pdb_put_packet (unsigned char *buffer, int ack); -static int pdb_initialized = 0; +int pdb_initialized = 0; static int pdb_serhnd = -1; #define RX_SIZE 32 diff --git a/xen/arch/i386/traps.c b/xen/arch/i386/traps.c index 31a59637c5..00a8fd2b52 100644 --- a/xen/arch/i386/traps.c +++ b/xen/arch/i386/traps.c @@ -196,6 +196,8 @@ static inline void do_trap(int trapnr, char *str, trap_info_t *ti; unsigned long fixup; + __sti(); + if (!(regs->xcs & 3)) goto fault_in_hypervisor; @@ -257,6 +259,8 @@ asmlinkage void do_int3(struct pt_regs *regs, long error_code) struct guest_trap_bounce *gtb = guest_trap_bounce+smp_processor_id(); trap_info_t *ti; + __sti(); + if ( (regs->xcs & 3) != 3 ) { if ( pdb_handle_exception(3, regs) == 0 ) @@ -323,6 +327,8 @@ asmlinkage void do_page_fault(struct pt_regs *regs, long error_code) __asm__ __volatile__ ("movl %%cr2,%0" : "=r" (addr) : ); + __sti(); + if ( unlikely(addr >= LDT_VIRT_START) && (addr < (LDT_VIRT_START + (p->mm.ldt_ents*LDT_ENTRY_SIZE))) ) { @@ -390,6 +396,8 @@ asmlinkage void do_general_protection(struct pt_regs *regs, long error_code) trap_info_t *ti; unsigned long fixup; + __sti(); + /* Badness if error in ring 0, or result of an interrupt. */ if ( !(regs->xcs & 3) || (error_code & 1) ) goto gp_in_kernel; @@ -498,6 +506,8 @@ asmlinkage void math_state_restore(struct pt_regs *regs, long error_code) /* Prevent recursion. */ clts(); + __sti(); + if ( !test_bit(PF_USEDFPU, ¤t->flags) ) { if ( test_bit(PF_DONEFPUINIT, ¤t->flags) ) @@ -516,36 +526,13 @@ asmlinkage void math_state_restore(struct pt_regs *regs, long error_code) } } -asmlinkage void do_debug(struct pt_regs * regs, long error_code) +asmlinkage void do_debug_orig(struct pt_regs *regs, long error_code) { unsigned int condition; struct task_struct *tsk = current; struct guest_trap_bounce *gtb = guest_trap_bounce+smp_processor_id(); - __asm__ __volatile__("movl %%db6,%0" : "=r" (condition)); - - if ((condition & (1 << 14)) != (1 << 14)) - { - printk ("\nwarning: debug trap w/o BS bit [0x%x]\n\n", condition); - } - __asm__("movl %0,%%db6" : : "r" (0)); - - if ( pdb_handle_exception(1, regs) != 0 ) - { - tsk->thread.debugreg[6] = condition; - - gtb->flags = GTBF_TRAP_NOCODE; - gtb->cs = tsk->thread.traps[1].cs; - gtb->eip = tsk->thread.traps[1].address; - } -} - - -asmlinkage void do_debug_orig(struct pt_regs * regs, long error_code) -{ - unsigned int condition; - struct task_struct *tsk = current; - struct guest_trap_bounce *gtb = guest_trap_bounce+smp_processor_id(); + __sti(); __asm__ __volatile__("movl %%db6,%0" : "=r" (condition)); @@ -580,6 +567,37 @@ asmlinkage void do_debug_orig(struct pt_regs * regs, long error_code) } +asmlinkage void do_debug(struct pt_regs *regs, long error_code) +{ + unsigned int condition; + struct task_struct *tsk = current; + struct guest_trap_bounce *gtb = guest_trap_bounce+smp_processor_id(); + + /* This handler is broken! Only use it if PDB is enabled. */ + if ( !pdb_initialized ) + { + do_debug_orig(regs, error_code); + return; + } + + __sti(); + + __asm__ __volatile__("movl %%db6,%0" : "=r" (condition)); + if ( (condition & (1 << 14)) != (1 << 14) ) + printk("\nwarning: debug trap w/o BS bit [0x%x]\n\n", condition); + __asm__("movl %0,%%db6" : : "r" (0)); + + if ( pdb_handle_exception(1, regs) != 0 ) + { + tsk->thread.debugreg[6] = condition; + + gtb->flags = GTBF_TRAP_NOCODE; + gtb->cs = tsk->thread.traps[1].cs; + gtb->eip = tsk->thread.traps[1].address; + } +} + + asmlinkage void do_spurious_interrupt_bug(struct pt_regs * regs, long error_code) { /* nothing */ } -- 2.30.2